#!/bin/sh

##############################################
# Configuration                              #
##############################################
# path variables
basePath=C:/PAPYRUS
eclipsePath=$basePath/Eclipse/Eclipse3.3.1.1/eclipse
toolsdir="C:/Program Files"/
equinoxLauncher=org.eclipse.equinox.launcher_1.0.1.R33x_v20070828.jar
pdeScriptBuilder=org.eclipse.pde.build_3.3.2.R331_v20071019

# build identification
buildType=N
buildId=`date +%Y%m%d` # buildId(date format : YYYYmmDD)
echo "buildID: "$buildId
buildLabel=Papyrus_$buildId
echo $buildLabel
version=1.9.1

# build directory
buildDirectory=$basePath/Build/RCP_RELEASE_1.9.1
binariesDir=$basePath/Resources/Binaries
relengDir=$buildDirectory/com.cea.papyrus.releng
productScriptsDir=$relengDir/scripts/product
updateSiteScriptsDir=$relengDir/scripts/updateSite


installerResourceDir=$buildDirectory/$buildLabel/Papyrus-$version

# map file dir
mapsRoot=$relengDir/maps/

# Repository version : head, release or branch for product plugin (here, org.usinelogicielle.platform) and for maps project!!
# possibilities : head or releases/1.4.5 or branch/1.7.X
tagPath=releases/1.9.1

###############################################################################
# METHODS
###############################################################################

############################################
# Clean Build Space
# clean files comming from previous builds
############################################
echo Cleaning build directories...
rm -vf $buildDirectory/*.properties
rm -vf $buildDirectory/*.xml
rm -vf $buildDirectory/directory.txt

# clean build dictories to have a clean place to export files
rm -rvf $buildDirectory/plugins
rm -rvf $buildDirectory/features
rm -rvf $buildDirectory/maps
rm -rvf $buildDirectory/result 
mkdir $buildDirectory/plugins
mkdir $buildDirectory/features
mkdir $buildDirectory/maps
mkdir $buildDirectory/result
echo Cleaning build directories ok.

# checkout maps file (not useful, maps are integrated in the releng project for Papyrus
echo Checkout map files 
cp --force $mapsRoot/*.map $buildDirectory/maps/ 
# svn --force export http://is002974.saclay.cea.fr/svn/OpenDevFactory/ODF_Platform/RCP/head/org.usinelogicielle.platform.maps $buildDirectory/maps

if [ $1 == 1 ] 
then
	cd $productScriptsDir
	echo
	echo ========== BUILDING PRODUCT ==========
	ls -al
	exec ./buildRCP.sh
fi

if [ $2 == 1 ]
then 
	cd $updateSiteScriptsDir
	echo ========== BUILDING UDPATE SITE ==========
	exec ./buildUpdateSite.sh
fi
		 

	

